Skip to content

ZOOKEEPER-4391: Allow custom JVM heap sizing - #2460

Open
jprieto-temporal wants to merge 4 commits into
apache:masterfrom
jprieto-temporal:jprieto/syyxuxtpmnum
Open

jprieto-temporal wants to merge 4 commits into
apache:masterfrom
jprieto-temporal:jprieto/syyxuxtpmnum

Conversation

@jprieto-temporal

@jprieto-temporal jprieto-temporal commented Sep 17, 2026 •

Copy link
Copy Markdown

Allow ZK_SERVER_HEAP and ZK_CLIENT_HEAP to use auto, which omits the generated -Xmx option. This enables settings such as -XX:MaxRAMPercentage through the existing JVM flags while preserving current defaults and numeric heap values.

Add a conf/java.env template and document the new behavior and update documentation.

I didn't follow the exact approach suggested in #2061 (review) because existing deployments may set JVMFLAGS for unrelated options while relying on ZooKeeper’s default heap limits. Removing the generated -Xmx in those cases would silently change their memory behavior. Using the explicit auto value makes the change opt-in.

@ctubbsii ctubbsii left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and simple concept, but I think the word "auto" is the wrong word to use. It appears to be chosen to manually configure JVM flags that affect automatic heap sizing. However, what it is actually doing is removing any automatically placed heap configuration fields. You can use that to add flags manually that do automatic heap sizing, but you can also use that to just omit those heap options for any other reason. With the word "auto", users may be confused that you need to set it to remove an automatic addition of heap options, so that you can use it (optionally) for different heap options.

So, I think something along the lines of "none", "skip", "custom", or "omit" should be used instead.

The instruction in the documention would then look something like:

Use `manual` to skip adding any heap options to the JVM environment automatically, so you can manually set any heap related flags yourself. For example:


```bash
ZK_SERVER_HEAP=omit \
SERVER_JVMFLAGS="-XX:InitialRAMPercentage=25 -XX:MaxRAMPercentage=75" \
./zkServer.sh start
```

or

```bash
ZK_SERVER_HEAP=omit \
SERVER_JVMFLAGS="-Xmx2g" \
./zkServer.sh start
```

@jprieto-temporal jprieto-temporal changed the title ZOOKEEPER-4391: Allow automatic JVM heap sizing ZOOKEEPER-4391: Allow custom JVM heap sizing Sep 18, 2026
@jprieto-temporal

Copy link
Copy Markdown
Author

@ctubbsii Thank you for the review. Yes, auto was a confusing choice by me. I've updated to use the word omit and updated the docs as you suggested.

@kezhuw kezhuw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

I think the word "auto" is the wrong word to use.

So, I think something along the lines of "none", "skip", "custom", or "omit" should be used instead.

Yes, auto was a confusing choice by me. I've updated to use the word omit and updated the docs as you suggested.

"ignore" could also be a candidate. I have no preference, but I think we should phrase the doc sentence carefully so we don't mislead users.

Comment thread zookeeper-website/app/pages/_docs/docs/_mdx/admin-ops/tools.mdx Outdated
Comment thread zookeeper-website/app/pages/_docs/docs/_mdx/admin-ops/tools.mdx Outdated

@kezhuw kezhuw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my side.

@kezhuw
kezhuw requested review from anmolnar and phunt September 18, 2026 13:46
@kezhuw

kezhuw commented Sep 18, 2026

Copy link
Copy Markdown
Member

Hi @jprieto-temporal, do you have a jira account or would you mind register a jira account so I can assign ZOOKEEPER-4391 to you ?

@jprieto-temporal

Copy link
Copy Markdown
Author

@kezhuw Thanks! Yes you can find me on jira by my name or username jiralover1985

@dukelion

Copy link
Copy Markdown
Contributor

I think #2398 solves this problem in a bit simpler way

@jprieto-temporal

Copy link
Copy Markdown
Author

@dukelion #2398 solves a different problem that I also think is worth addressing. This PR is a bit different and concerns the contents of JVMFLAGS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants